// pages/component/promotions/promotebalance/promotebalance.js   /purchase/moneyrecharge/moneyrecharge

var GlobalData = require('../../../../utils/GlobalData.js');
var dataManager = require('../../../../utils/dataManager.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    balanceData: {},
    hidden: true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示 promotebalance
   */
  onShow: function () {
    dataManager.removeBtnObserver("promotebalance")
    this.setData({
      hidden: true
    })
    dataManager.rigisterObserver('promotebalance', this.onComplete, this);
    dataManager.getPromoteBalance();

  },
  onComplete() {
    this.setData({
      balanceData: GlobalData.PromoteBalance
    })
    // console.log(this.data.balanceData);

  },
  /**前往推广详细 */
  /**查看收益明细 */
  goEarningDetail: function () {
    this.setData({
      hidden: false
    })
    dataManager.OnRequestPost({ method: "getpromoterebatelist", "token": GlobalData.token, "pageindex": GlobalData.EarningDetailother["index"], "pagesize": GlobalData.EarningDetailother["size"] }, this.onProcessEarning, false, this.onError);
  },
  onError: function () {
    this.setData({
      hidden: true
    })
  },
  onProcessEarning: function (data) {
    for (let i = 0; i < data.length; i++) {
      GlobalData.EarningDetail[i] = GlobalData.clone(data[i]);
    }
    // if (dataManager.isClick("earningdetail")) {
    //   return
    // } else {
    //   dataManager.btnObserver("earningdetail")
    this.setData({
      hidden: true
    })
    dataManager.UseNavigateTo('../../homes/earningdetail/earningdetail', false);
    // }

  },

  /**前往提现 */
  goWithdraw: function () {
    // if (dataManager.isClick("withdraw")) {
    //   return
    // } else {
    //   dataManager.btnObserver("withdraw")
    this.setData({
      hidden: false
    })
    dataManager.UseNavigateTo('../../homes/withdraw/withdraw', false);
    // }


  },
  /**前往转账 */
  goTransfer: function () {
    // if (dataManager.isClick("transfer")) {
    //   return
    // } else {
    //   dataManager.btnObserver("transfer")
    this.setData({
      hidden: false
    })
    dataManager.UseNavigateTo('../../homes/transfer/transfer', false);
    // }

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {

  // }
})